import axios from "axios";

const serverConfig = {
    // 开发环境
    development: {
        APIBaseURL: 'http://localhost:8080/api/',
    },
    // 线上环境
    production: {
        APIBaseURL: 'https://api.account.samler.cn/',
    }
}

const request = axios.create({baseURL: serverConfig[process.env.NODE_ENV].APIBaseURL})
request.interceptors.response.use(
    resp => {
        if(resp.status === 200) {
            return resp.data
        }

        return Promise.reject(resp)
    }
)

export {
    request
}
